DATASET ACTIVATE DataSet1. * DHS Calendar Tutorial - Example 4. * Stillbirths and perinatal mortality. * download the model dataset for individual women's recode: "ZZIR62FL.SAV" * the model datasets are available at http://dhsprogram.com/data/download-model-datasets.cfm . * change to a working directory where the data are stored * or add the full path to the 'get file' command below. cd "C:\Data\DHS_model". * open the dataset to use, and just keep the variables we are going to use. get file="ZZIR62FL.SAV" / keep vcal$1 v000 v005 v007 v008 v018 v021 v023 v024 b3$01 to b3$20 b6$01 to b6$20. * set maximum number of loops high enough. Could be as many as the length of the calendar (80) * so set it a bit higher. set mxloops = 100. * Step 4.1. * Stillbirths. compute stillbirths = 0. variable labels stillbirths "Stillbirths". * Births in calendar. compute births = 0. variable labels births "Births in calendar (excludes twins)". * Births in birth history including twins in the five years preceding the survey. compute births2 = 0. variable labels births2 "Births in birth history (including twins)". * Early neonatal deaths in the five years preceding the survey. compute earlyneo = 0. variable labels earlyneo "Early neonatal deaths". * Step 4.2. * Set the start and end positions to use for the five year windows. compute beg = v018. compute end = v018 + 59. * Loop through calendar summing births and stillbirths (a termination of 7+ months). * restrict to just the 60 months preceding survey. loop #i = beg to end. * scount the births. + if (char.substr(vcal$1,#i,1) = "B") births = births+1. * count the stillbirths. + if (char.substr(vcal$1,#i,7) = "TPPPPPP") stillbirths = stillbirths+1. end loop. execute. * Step 4.3. * reuse beg and end for CMCs range for the birth history. compute end = v008. compute beg = v008-59. * convert b3 and b6 variables into vectors to facilitate use in the loop. vector B3 = B3$01 to B3$20. vector B6 = B6$01 to B6$20. * Loop through birth history summing births and early neonatal deaths * in the five years preceding the survey. loop #i = 1 to 20. * Restrict to 60 months preceding survey. + if (B3(#i) >= beg & B3(#i) <= end) births2 = births2+1. + if (B3(#i) >= beg & B3(#i) <= end & B6(#i) >= 100 & B6(#i) <= 106) earlyneo = earlyneo+1. end loop. execute. * Step 4.4. * total pregnancies of 7+ months in last 5 years (all live births (including twins), * plus the stillbirths). compute totpreg7m = births2+stillbirths. variable labels totpreg7m "Number of pregnancies of 7+ months duration". * total perinatal mortality = early neonatal deaths plus stillbirths. compute perinatal = earlyneo+stillbirths. variable labels perinatal "Perinatal mortality". * Step 4.5. * create weight variable. compute wt = v005/1000000. weight by wt. * number of stillbirths. * weight the number of women by the number of stillbirths for the correct count. compute wt = stillbirths*v005/1000000. frequencies variables=v024. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight |wt | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|42 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=v024. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.01 | |---------------------------------------------------------------------------------------------------------| Statistics V024 Region |-|-------|--| |N|Valid |34| | |-------|--| | |Missing|0 | |------------| V024 Region |--------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-----|--------|---------|-------|-------------|------------------| |Valid|Region 1|16 |46.9 |46.9 |46.9 | | |--------|---------|-------|-------------|------------------| | |Region 2|5 |15.9 |15.9 |62.9 | | |--------|---------|-------|-------------|------------------| | |Region 3|1 |4.1 |4.1 |67.0 | | |--------|---------|-------|-------------|------------------| | |Region 4|11 |33.0 |33.0 |100.0 | | |--------|---------|-------|-------------|------------------| | |Total |34 |100.0 |100.0 | | |-----------------------------------------------------------------| Warning # 3211 On at least one case, the value of the weight variable was zero, negative, or missing. Such cases are invisible to statistical procedures and graphs which need positively weighted cases, but remain on the file and are processed by non-statistical facilities such as LIST and SAVE. * number of early neonatal deaths. * weight the number of women by the number of early neonatal deaths. compute wt = earlyneo*v005/1000000. frequencies variables=v024. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight |wt | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|152 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=v024. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.00 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.02 | |---------------------------------------------------------------------------------------------------------| Statistics V024 Region |-|-------|---| |N|Valid |177| | |-------|---| | |Missing|0 | |-------------| V024 Region |--------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-----|--------|---------|-------|-------------|------------------| |Valid|Region 1|38 |21.7 |21.7 |21.7 | | |--------|---------|-------|-------------|------------------| | |Region 2|40 |22.8 |22.8 |44.4 | | |--------|---------|-------|-------------|------------------| | |Region 3|55 |31.0 |31.0 |75.4 | | |--------|---------|-------|-------------|------------------| | |Region 4|43 |24.6 |24.6 |100.0 | | |--------|---------|-------|-------------|------------------| | |Total |177 |100.0 |100.0 | | |-----------------------------------------------------------------| Warning # 3211 On at least one case, the value of the weight variable was zero, negative, or missing. Such cases are invisible to statistical procedures and graphs which need positively weighted cases, but remain on the file and are processed by non-statistical facilities such as LIST and SAVE. * number of pregnancies of 7+ months. * weight the number of women by the total number of pregnancies of 7+ months. compute wt = totpreg7m*v005/1000000. frequencies variables=v024. Frequencies Notes |-----------------------------------------------------|---------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |-----------------------------------------------------|---------------------------------------------------| |Comments | | |----------------------|------------------------------|---------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------| | |Weight |wt | | |------------------------------|---------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------| | |N of Rows in Working Data File|4276 | |----------------------|------------------------------|---------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values are treated as missing.| | |------------------------------|---------------------------------------------------| | |Cases Used |Statistics are based on all cases with valid data. | |-----------------------------------------------------|---------------------------------------------------| |Syntax |frequencies variables=v024. | |----------------------|------------------------------|---------------------------------------------------| |Resources |Processor Time |00:00:00.02 | | |------------------------------|---------------------------------------------------| | |Elapsed Time |00:00:00.02 | |---------------------------------------------------------------------------------------------------------| Statistics V024 Region |-|-------|----| |N|Valid |5906| | |-------|----| | |Missing|0 | |--------------| V024 Region |--------------|---------|-------|-------------|------------------| | |Frequency|Percent|Valid Percent|Cumulative Percent| |-----|--------|---------|-------|-------------|------------------| |Valid|Region 1|2178 |36.9 |36.9 |36.9 | | |--------|---------|-------|-------------|------------------| | |Region 2|1315 |22.3 |22.3 |59.1 | | |--------|---------|-------|-------------|------------------| | |Region 3|1101 |18.6 |18.6 |77.8 | | |--------|---------|-------|-------------|------------------| | |Region 4|1313 |22.2 |22.2 |100.0 | | |--------|---------|-------|-------------|------------------| | |Total |5906 |100.0 |100.0 | | |-----------------------------------------------------------------| Warning # 3211 On at least one case, the value of the weight variable was zero, negative, or missing. Such cases are invisible to statistical procedures and graphs which need positively weighted cases, but remain on the file and are processed by non-statistical facilities such as LIST and SAVE. * reset the weight variable. compute wt = v005/1000000. * turn off weighting as the complex samples procedures don't use the weight * from the 'weight by' command, but use it from the csplan instead. * this eliminates a confusing warning message about the weight being ignored. weight off. * complex sample for use with DHS calendar data. csplan analysis /plan file='Calendar.csaplan' /planvars analysisweight=wt /srsestimator type=wor /design strata=v023 cluster=v021 /estimator type=wr. Complex Samples: Plan Notes |---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Comments | | |--------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | |Weight | | | |------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|4276 | |---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Syntax |csplan analysis /plan file='Calendar.csaplan' /planvars analysisweight=wt /srsestimator type=wor /design strata=v023 cluster=v021 /estimator type=wr.| |--------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.00 | | |------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.03 | |--------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| |Files Saved |Plan File |C:\Data\DHS_model\Calendar.csaplan | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Warnings |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |This procedure does not check the consistency of the working data file with the plan file. We recommend looking at the output table or the plan file to check consistency before performing selection or analysis.| |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Summary |-------------------------------------------|-----------------------------------------| | |Stage 1 | |--------------------|--------------------|-|-----------------------------------------| |Design Variables |Stratification |1|V023 Stratification used in sample design| | |--------------------|-|-----------------------------------------| | |Cluster |1|V021 Primary sampling unit | |--------------------|----------------------|-----------------------------------------| |Analysis Information|Estimator Assumption |Sampling with replacement | |-------------------------------------------|-----------------------------------------| | | | |-------------------------------------------------------------------------------------| Plan File: C:\Data\DHS_model\Calendar.csaplan Weight Variable: wt SRS Estimator: Sampling without replacement * complex samples ratio for the perinatal mortality rate. csdescriptives /plan file='Calendar.csaplan' /ratio numerator=perinatal denominator=totpreg7m /statistics se /subpop table=v024. Complex Samples: Descriptives Notes |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Comments | | |----------------------|------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |Weight | | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |Plan File |C:\Data\DHS_model\Calendar.csaplan | |----------------------|------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Missing Value Handling|Definition of Missing |User-defined missing values among the strata, cluster, or subpopulation variables are treated as missing. | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |Cases Used |Each statistic is based on all valid data for the analysis variable(s) used in computing the statistic. | |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Syntax |csdescriptives /plan file='Calendar.csaplan' /ratio numerator=perinatal denominator=totpreg7m /statistics se /subpop table=v024.| |----------------------|------------------------------|------------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.03 | | |------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.04 | |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Ratios 1 |-----------------------------|-----------------------------------------------------|--------------|--------------| |Numerator |Denominator |Ratio Estimate|Standard Error| |-----------------------------|-----------------------------------------------------|--------------|--------------| |perinatal Perinatal mortality|totpreg7m Number of pregnancies of 7+ months duration|.036 |.003 | |-----------------------------------------------------------------------------------------------------------------| Subpopulation Descriptives Ratios 1 |-----------|-----------------------------|-----------------------------------------------------|--------------|--------------| |V024 Region|Numerator |Denominator |Ratio Estimate|Standard Error| |-----------|-----------------------------|-----------------------------------------------------|--------------|--------------| |Region 1 |perinatal Perinatal mortality|totpreg7m Number of pregnancies of 7+ months duration|.025 |.004 | |-----------|-----------------------------|-----------------------------------------------------|--------------|--------------| |Region 2 |perinatal Perinatal mortality|totpreg7m Number of pregnancies of 7+ months duration|.035 |.006 | |-----------|-----------------------------|-----------------------------------------------------|--------------|--------------| |Region 3 |perinatal Perinatal mortality|totpreg7m Number of pregnancies of 7+ months duration|.051 |.011 | |-----------|-----------------------------|-----------------------------------------------------|--------------|--------------| |Region 4 |perinatal Perinatal mortality|totpreg7m Number of pregnancies of 7+ months duration|.041 |.006 | |-----------------------------------------------------------------------------------------------------------------------------| * Ratio doesn't permit the use of non-integer weights, * so use the weight without dividing by a million. compute wt = v005. weight by wt. * perinatal mortality rate. ratio statistics perinatal with totpreg7m by v024 /print wgtmean. Ratio Statistics Notes |-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Output Created |31-AUG-2017 01:17:03 | |-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Comments | | |----------------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Input |Filter | | | |------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | |Weight |wt | | |------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | |Split File | | | |------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | |N of Rows in Working Data File|8348 | |----------------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Missing Value Handling|Definition of Missing |A case is treated as missing when it contains system and/or user-defined missing values in any variables used for this analysis. | | |------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | |Cases Used |Cases used have non-negative values in the numerator variable and positive values in the denominator variable, and have no missing values in the group variable.| |-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Syntax |ratio statistics perinatal with totpreg7m by v024 /print wgtmean. | |----------------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| |Resources |Processor Time |00:00:00.03 | | |------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | |Elapsed Time |00:00:00.07 | |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Case Processing Summary |------------------------|--------------|-------| | |Count |Percent| |---------------|--------|--------------|-------| |V024 Region |Region 1|1546858758.00 |36.9% | | |--------|--------------|-------| | |Region 2|898127795.00 |21.5% | | |--------|--------------|-------| | |Region 3|816523742.00 |19.5% | | |--------|--------------|-------| | |Region 4|925497591.00 |22.1% | |------------------------|--------------|-------| |Overall |4187007886.00a|100.0% | |---------------|--------|--------------|-------| |Number of Cases|Included|4276 | | | |--------|--------------|-------| | |Excluded|4072 | | | |--------|--------------|-------| | |Total |8348 | | |-----------------------------------------------| a The replication weight: wt is applied. Ratio Statistics for perinatal Perinatal mortality / totpreg7m Number of pregnancies of 7+ months duration |--------|-------------| |Group |Weighted Mean| |--------|-------------| |Region 1|.025 | |--------|-------------| |Region 2|.035 | |--------|-------------| |Region 3|.051 | |--------|-------------| |Region 4|.041 | |--------|-------------| |Overall |.036 | |----------------------|